
from django.core.management.base import BaseCommand
from movie.models import Category

class Command(BaseCommand):
    help = '初始化电影分类'

    def handle(self, *args, **kwargs):
        self.stdout.write(self.style.SUCCESS('开始初始化电影分类'))
        # 此处应先创建 category.json 文件，以下示例为假设根据 model 生成初始数据的逻辑
        categories_data = [
            {'category_name': '电影'}, 
            {'category_name': '电视剧'},
            {'category_name': '综艺'},
            {'category_name': '动漫'},
            {'category_name': '纪录片'},
            {'category_name': '短片'},
            {'category_name': '其他'},
        ]
        Category.objects.bulk_create([Category(**data) for data in categories_data])
        
        self.stdout.write(self.style.SUCCESS('电影分类初始化完成'))